let foo = 'get-element-by-id'
function charToTuo (str) {
  let arr = str.split('-')
  for (let i = 0; i < arr.length; i++) {
    arr[i] = arr[i].replace(arr[i][0], arr[i][0].toUpperCase())
  }
  return arr.join('-')
}
function charToTuo (str) {
  let reg = /-(\w)/g
  return str.replace(reg, function ($0, $1) {
    console.log($1);
    return '-' + $1.toUpperCase()
  })
}
console.log(charToTuo(foo));